<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>登录页面 - 后台管理系统</title>
    <link rel="icon" href="favicon.ico" type="image/ico">
    <meta name="keywords" content="LightYear,后台模板,后台管理系统">
    <meta name="description" content="LightYear是一个基于Bootstrap v3.3.7的后台管理系统的HTML模板。">
    <link rel="stylesheet" href="../css/bootstrap.css">
    <link rel="stylesheet" href="../css//materialdesignicons.min.css">
    <!-- <link href="css/style.min.css" rel="stylesheet"> -->
    <style>
        body {
            background-color: #f5f6fa;
        }

        .topbar {
            background-color: #fff;
        }

        .inquire {
            width: 20vw;
        }

        .content {
            padding: 5rem;
            /* display: none; */
        }

        th {
            text-align: center;
        }

        .rows {
            width: 100%;
            display: flex;
            justify-content: space-between;
            margin: 1rem 0;
        }

        .chaxun {
            display: flex;
            align-items: flex-start;
        }

        .addacademy {
            position: fixed;
            top: 0;
            right: -560px;
            width: 560px;
            height: 100vh;
            background-color: #fff;
            border-left: 1px solid pink;
            padding: 7vh 20px;
            transition: all 0.2s linear;
        }

        .form-group {
            margin-top: 40px;
        }

        .form-group-footer button {
            width: 10vw;
        }

        .form-group-footer {
            display: flex;
            justify-content: space-around;
            align-items: flex-end;
        }

        .table>tbody>tr>td,
        .table>tbody>tr>th,
        .table>tfoot>tr>td,
        .table>tfoot>tr>th,
        .table>thead>tr>td,
        .table>thead>tr>th {
            vertical-align: middle;
        }

        .view {
            position: fixed;
            top: 0;
            right: 0;
            width: 100vw;
            height: 100vh;
            background-color: #f5f6fa;
            transition: all 0.2s linear;
            border-top: 1px solid pink;
            display: none;
        }

        .view-header-title {
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

        .view-header-select {
            margin: 1vw;
            display: flex;
            justify-content: center;
            align-items: center;
        }

        .view-header-select select {
            width: 350px;
            margin: 0 10px;
        }

        .view-content {
            padding: 5rem;
        }

        .behavioralExpression {
            position: fixed;
            top: 0;
            right: -560px;
            width: 560px;
            height: 100vh;
            background-color: #fff;
            border-left: 1px solid pink;
            padding: 10vh 20px;
            transition: all 0.2s linear;
            border-top: 1px solid pink;
        }


        .behavioralExpression-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

        .Pageys {
            text-align: center;
        }

        #schoolLogo {
            width: 15vw;
        }
    </style>
</head>

<body>
    <button type="button" class="btn btn-primary btn-lg tanchuang" data-toggle="modal" data-target="#myModal"
        style="display: none;">
        Launch demo modal
    </button>

    <!-- Modal -->
    <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                            aria-hidden="true">&times;</span></button>
                    <h4 class="modal-title" id="myModalLabel">Modal title</h4>
                </div>
                <div class="modal-body">
                    ...
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                    <button type="button" class="btn btn-primary">Save changes</button>
                </div>
            </div>
        </div>
    </div>
    <div class="content">
        <div class="rows">
            <div>
                <a class="btn btn-primary m-r-5" onclick="addschool()"><span class="glyphicon glyphicon-plus"
                        aria-hidden="true"></span> 新增</a>
            </div>
            <div class="chaxun">
                <input type="text" class="form-control inquire fuzzyQuery" placeholder="输入城市或院校关键字，例如河北-石家庄">
                <button type="button" class="btn btn-default" onclick="search()">查询</button>
            </div>
        </div>
        <table class="table table-striped table-hover table-bordered"
            style="background-color: #fff; text-align: center;">
            <thead>
                <tr>
                    <th>序号</th>
                    <th>城市</th>
                    <th>学校</th>
                    <th>负责人</th>
                    <th>职务</th>
                    <th>负责人电话</th>
                    <th>创建时间</th>
                    <th>学校学生人数</th>
                    <th>操作</th>
                </tr>
            </thead>
            <tbody class="tbodycg">
                <!-- <tr>
                    <td>1</td>
                    <td>1</td>
                    <td>1</td>
                    <td>1</td>
                    <td>1</td>
                    <td>1</td>
                    <td>1</td>
                    <td>1</td>
                    <td><button class="btn btn-primary m-r-5" onclick="view()">查看</button></td>
                </tr> -->
            </tbody>
        </table>
        <div class="kong" style="text-align: center;"></div>
        <nav aria-label="Page navigation" class="Pageys">
            <ul class="pagination">
                <li onclick="prev()">
                    <a href="#" aria-label="Previous">
                        <!-- <span aria-hidden="true">&laquo;</span> -->
                        <span aria-hidden="true">上一页</span>
                    </a>
                </li>
                <li><a href="#" class="cgys">1</a></li>
                <li><a>···</a></li>
                <li onclick="next()">
                    <a href="#" aria-label="Next">
                        <!-- <span aria-hidden="true">&raquo;</span> -->
                        <span aria-hidden="true">下一页</span>
                    </a>
                </li>
            </ul>
        </nav>
    </div>
    <div class="addacademy">
        <h2>添加院校</h2>
        <form class="form-horizontal">
            <div class="form-group">
                <label for="inputcity" class="col-sm-2 control-label">城市</label>
                <div class="col-sm-10">
                    <input type="text" class="form-control" id="inputcity" placeholder="城市">
                </div>
            </div>
            <div class="form-group">
                <label for="inputschool" class="col-sm-2 control-label">学校</label>
                <div class="col-sm-10">
                    <input type="text" class="form-control" id="inputschool" placeholder="学校">
                </div>
            </div>
            <div class="form-group">
                <label for="inputfunctionary" class="col-sm-2 control-label">负责人</label>
                <div class="col-sm-10">
                    <input type="text" class="form-control" id="inputfunctionary" placeholder="负责人">
                </div>
            </div>
            <div class="form-group">
                <label for="inputpost" class="col-sm-2 control-label">职务</label>
                <div class="col-sm-10">
                    <input type="text" class="form-control" id="inputpost" placeholder="职务">
                </div>
            </div>
            <div class="form-group">
                <label for="inputfunctionaryphone" class="col-sm-2 control-label">负责人电话</label>
                <div class="col-sm-10">
                    <input type="text" class="form-control" id="inputfunctionaryphone" placeholder="负责人电话">
                </div>
            </div>
            <div class="form-group">
                <label for="inputfunctionaryphone" class="col-sm-2 control-label">学校logo</label>
                <div class="col-sm-10">
                    <span onclick="files()">点击</span>
                    <input type="file" id="fileS" style="display: none;">
                    <div></div>
                </div>
            </div>
            <div class="form-group  form-group-footer">
                <button class="btn btn-block btn-primary" type="button" onclick="addacademys()">确定添加</button>
                <button class="btn btn-block btn-primary" type="button" onclick="closeaddacademy()">取消添加</button>
            </div>
        </form>
    </div>
    <div class="view">
        <div class="view-header">
            <div class="view-header-title topbar">
                <div>
                    <!-- <h2 id="schoolLogo">某某某院校</h2> -->
                    <img src="" alt="" id="schoolLogo">
                </div>
                <div>
                    <button type="button" class="btn btn-primary" onclick="closeview()">关闭</button>
                </div>
            </div>
            <div class="view-header-select">
                <select class="form-control" id="specialty">
                </select>
                <select class="form-control" id="grades">
                </select>
                <button type="button" class="btn btn-default" id="searchstucx" onclick="searchstu()">查询</button>
            </div>
        </div>
        <div class="view-content">
            <table class="table table-striped table-hover table-bordered"
                style="background-color: #fff; text-align: center;">
                <thead id="theadstu">
                    <!-- <tr>
                        <th>序号</th>
                        <th>学生姓名</th>
                        <th>专业</th>
                        <th>班级</th>
                        <th>入学时间</th>
                        <th>当前学年学分</th>
                        <th>搜属地</th>
                        <th>性别</th>
                        <th>联系方式</th>
                        <th>操作</th>
                    </tr> -->
                </thead>
                <tbody id="tbody2">
                    <!-- <tr>
                        <td>1</td>
                        <td>1</td>
                        <td>1</td>
                        <td>1</td>
                        <td>1</td>
                        <td>1</td>
                        <td>1</td>
                        <td>1</td>
                        <td>1</td>
                        <td><button class="btn btn-primary m-r-5" onclick="behavioralExpressionBox()">过往表现</button>
                        </td>
                    </tr> -->
                </tbody>
            </table>
            <nav aria-label="Page navigation" class="Pageys">
                <ul class="pagination">
                    <li onclick="prevstu()">
                        <a href="#" aria-label="Previous">
                            <span aria-hidden="true">上一页</span>
                        </a>
                    </li>
                    <li><a href="#" class="studentys">1</a></li>
                    <li><a href="#">···</a></li>
                    <li onclick="nextstu()">
                        <a href="#" aria-label="Next">
                            <span aria-hidden="true">下一页</span>
                        </a>
                    </li>
                </ul>
            </nav>
            <div class="behavioralExpression">

                <div class="behavioralExpression-header">
                    <div>
                        <h2>过往表现</h2>
                    </div>
                    <div>
                        <button class="btn btn-primary" onclick="closebehavioralExpression()">关闭</button>
                    </div>
                </div>

                <table class="table table-striped table-hover table-bordered"
                    style="background-color: #fff; text-align: center;">
                    <thead>
                        <tr>
                            <th>序号</th>
                            <th>时间</th>
                            <th>表现</th>
                        </tr>
                    </thead>
                    <tbody class="behavioralExpressionystbody">
                        </tbody>
                        </table>
                        <nav aria-label="Page navigation" class="Pageys">
                            <ul class="pagination">
                                <li onclick="prevbehavioralExpression()">
                                    <a href="#" aria-label="Previous">
                                        <span aria-hidden="true">上一页</span>
                                        </a>
                                        </li>
                                        <li><a href="#" class="behavioralExpressionys">1</a></li>
                                        <li><a href="#">···</a></li>
                                        <li onclick="nextbehavioralExpression()">
                                            <a href="#" aria-label="Next">
                                                <span aria-hidden="true">下一页</span>
                                                </a>
                                                </li>
                                                </ul>
                                                </nav>
            </div>
        </div>
        <!-- <div class="card-toolbar d-flex flex-column flex-md-row">
        <div class="toolbar-btn-action">
            <a class="btn btn-primary m-r-5" href="#!"><i class="mdi mdi-plus"></i> 新增</a>
            <a class="btn btn-success m-r-5 ajax-post confirm" href="" target-form="ids"><i class="mdi mdi-check"></i>
                启用</a>
            <a class="btn btn-warning m-r-5" href="#!"><i class="mdi mdi-block-helper"></i> 禁用</a>
            <a class="btn btn-danger" href="#!"><i class="mdi mdi-window-close"></i> 删除</a>
        </div>
    </div> -->
        <script src="../js/jquery.min.js"></script>
        <script src="../js/bootstrap.min.js"></script>
        <script src="../js/pubilc.js"></script>
        <script>
            // console.log(sessionStorage.getItem('token'))
            //手机号正则验证
            let reg = /^[1][3,4,5,6,7,8,9][0-9]{9}$/;
            var modal = document.querySelector('.modal')
            var addacademy = document.querySelector(".addacademy");
            var tanchuang = document.querySelector('.tanchuang')
            var modalTitle = document.querySelector('.modal-title')
            var kong = document.querySelector('.kong')
            var tbodycg = document.querySelector('.tbodycg')
            var cgys = document.querySelector('.cgys')
            var studentys = document.querySelector('.studentys')
            var behavioralExpressionys = document.querySelector('.behavioralExpressionys')

            var formUrl;
            var data;
            var data2;
            var data3;

            //超管院校分页
            function next() {
                var ys;
                if (Number(cgys.innerHTML) >= Math.ceil(data / 5)) {
                    return
                }
                ys = Number(cgys.innerHTML) + 1
                cgys.innerHTML = ys
                init()
            }
            function prev() {
                var ys;
                if (Number(cgys.innerHTML) <= 1) {
                    return
                }
                ys = Number(cgys.innerHTML) - 1
                cgys.innerHTML = ys
                init()
            }

            function nextstu() {
                var ys;
                if (Number(studentys.innerHTML) >= Math.ceil(data2 / 5)) {
                    return
                }
                ys = Number(studentys.innerHTML) + 1
                studentys.innerHTML = ys
                // init()
            }
            function prevstu() {
                var ys;
                if (Number(studentys.innerHTML) <= 1) {
                    return
                }
                ys = Number(studentys.innerHTML) - 1
                studentys.innerHTML = ys
            }
            function nextbehavioralExpression() {
                var ys;
                if (Number(behavioralExpressionys.innerHTML) >= Math.ceil(data3 / 5)) {
                    return
                }
                ys = Number(behavioralExpressionys.innerHTML) + 1
                behavioralExpressionys.innerHTML = ys
            }
            function prevbehavioralExpression() {
                var ys;
                if (Number(behavioralExpressionys.innerHTML) <= 1) {
                    return
                }
                ys = Number(behavioralExpressionys.innerHTML) - 1
                behavioralExpressionys.innerHTML = ys
            }
            //文件上传



            //模糊查询
            function search() {
                var fuzzyQuery = document.querySelector('.fuzzyQuery')
                console.log(fuzzyQuery.value)
                if (fuzzyQuery.value == '') {
                    cgys.innerHTML = '1'
                    init()
                } else {
                    tbodycg.innerHTML = ''
                    xhr({
                        methods: 'get',
                        url: '/user/getSchool',
                        success: function (res) {
                            console.log(res)
                            var box = []
                            for (var i = 0; i < res.length; i++) {
                                if (res[i].school_city_name.includes(fuzzyQuery.value) == true || res[i].school_name.includes(fuzzyQuery.value) == true) {
                                    console.log('123')
                                    box.push(res[i])
                                }
                            }
                            for (var i = Number(cgys.innerHTML - 1) * 5; i < box.length; i++) {
                                if (i >= (Number(cgys.innerHTML) * 5)) {
                                    break
                                } else {
                                    tbodycg.innerHTML += `
                                <tr>
                                   <td>${i + 1}</td>    
                                   <td>${box[i].school_city_name}</td>
                                   <td>${box[i].school_name}</td>
                                   <td>${box[i].school_duty}</td>
                                   <td>${box[i].school_duty_position}</td>
                                   <td>${box[i].school_phone}</td>
                                   <td>${box[i].createdAt}</td>
                                   <td>${box[i].school_student_num}</td>
                                   <td><a class="btn btn-primary m-r-5" onclick="view(${box[i].school_menu_ids})">查看院校信息</a></td>
                                <tr>
                                `
                                }
                            }
                        }
                    })
                    // kong.innerHTML = '<span>暂无数据</span>'
                }
            }
            function searchstu() {
                var ides = sessionStorage.getItem('school_id')
                var specialty = document.querySelector('#specialty').value
                var grades = document.querySelector('#grades').value
                console.log(specialty,grades)
                if(specialty && grades){
                    xhr({
                    methods: 'post',
                    url: '/student/getList',
                    data: JSON.stringify({
                        student_grade:specialty,
                        student_class:grades,
                        page: studentys.innerHTML,
                        limit: 5,
                        student_school: ides
                    }),
                    success: function (res) {
                        tbody2.innerHTML = ''
                        console.log(res)
                        var arr = res
                        data2 = res.length
                        xhr({
                                methods: 'get',
                                url: `/specialty/get?school_id=${Number(ides)}`,
                                success: function (res) {
                                    console.log(res)
                                    var zy = res
                                    for (var i = Number(studentys.innerHTML - 1) * 5; i < arr.length; i++) {

                                            if (res[k].specialty_id == arr[i].specialty_id) {
                                                if(arr[i].atScore){
                                                    tbody2.innerHTML += `
                                                    <tr>
                                                    <td>${i + 1}</td> 
                                                    <td>${arr[i].student_name}</td>
                                                    <td>${zy[k].specialty_name}</td>
                                                    <td>${arr[i].student_class}</td>
                                                    <td>${arr[i].student_age}</td>
                                                    <td>${arr[i].atScore}</td>
                                                    <td>${arr[i].student_address}</td>
                                                    <td>${arr[i].student_sex}</td>
                                                    <td>${arr[i].student_phone}</td>
                                                    <td><button class="btn btn-primary m-r-5" onclick="behavioralExpressionBox(${arr[i].Id})">过往表现</button>
                                                    </td>
                                                </tr>
                                                    `
                                                }else{
                                                    tbody2.innerHTML += `
                                                    <tr>
                                                    <td>${i + 1}</td> 
                                                    <td>${arr[i].student_name}</td>
                                                    <td>${zy[k].specialty_name}</td>
                                                    <td>${arr[i].student_class}</td>
                                                    <td>${arr[i].student_age}</td>
                                                    <td>---</td>
                                                    <td>${arr[i].student_address}</td>
                                                    <td>${arr[i].student_sex}</td>
                                                    <td>${arr[i].student_phone}</td>
                                                    <td><button class="btn btn-primary m-r-5" onclick="behavioralExpressionBox(${arr[i].Id})">过往表现</button>
                                                    </td>
                                                </tr>
                                                    `
                                                }
                                                        
                                                
                                            }
                                        }
                                }
                        })
                    }
                })
                }
                if(specialty == '' &&  grades == ''){
                    view(ides)
                }
            }
            init()
            function init() {
                tbodycg.innerHTML = ''
                console.log(cgys.innerHTML)
                xhr({
                    methods: 'get',
                    url: '/user/getSchool',
                    success: function (res) {
                        // console.log(res)
                        data = res.length
                        for (var i = Number(cgys.innerHTML - 1) * 5; i < res.length; i++) {
                            if (i >= (Number(cgys.innerHTML) * 5)) {
                                break
                            } else {
                                // var arr = res[i].school_menu_ids.split(",")
                                // console.log(arr)
                                tbodycg.innerHTML += `
                                <tr>
                                   <td>${i + 1}</td>    
                                   <td>${res[i].school_city_name}</td>
                                   <td>${res[i].school_name}</td>
                                   <td>${res[i].school_duty}</td>
                                   <td>${res[i].school_duty_position}</td>
                                   <td>${res[i].school_phone}</td>
                                   <td>${res[i].createdAt}</td>
                                   <td>${res[i].school_student_num}</td>
                                   <td><a class="btn btn-primary m-r-5" onclick="view(${res[i].school_id})">查看院校信息</a></td>
                                <tr>
                                `
                                // console.log(res[i].school_menu_ids)
                            }
                        }
                    }
                })
            }

            //添加院校
            function addacademys() {
                if (!inputcity.value || !inputschool.value || !inputfunctionary.value || !inputpost.value || !inputfunctionaryphone.value) {
                    // alert('请填写完整信息')
                    console.log(modal)
                    modal.style.display = 'block'
                    modal.querySelector('.modal-body').innerHTML = '请填写完整信息'
                    modal.querySelector('.modal-footer').innerHTML = '<button type="button" class="btn btn-primary" data-dismiss="modal" aria-label="Close">关闭</button>'
                    modalTitle.innerHTML = '<h2>提示</h2>'
                    tanchuang.click()
                    return
                }
                if (!reg.test(inputfunctionaryphone.value)) {
                    modal.style.display = 'block'
                    modal.querySelector('.modal-body').innerHTML = '请填写正确手机号'
                    modal.querySelector('.modal-footer').innerHTML = '<button type="button" class="btn btn-primary" data-dismiss="modal" aria-label="Close">关闭</button>'
                    modalTitle.innerHTML = '<h2>提示</h2>'
                    tanchuang.click()
                    return
                }
                console.log(inputschool.value, inputcity.value, inputfunctionaryphone.value, inputfunctionary.value, inputpost.value, formUrl)
                xhr({
                    methods: 'post',
                    url: '/user/addSchool',
                    data: JSON.stringify({
                        school_name: inputschool.value,
                        school_city_name: inputcity.value,
                        school_phone: inputfunctionaryphone.value,
                        school_duty: inputfunctionary.value,
                        school_duty_position: inputpost.value,
                        school_logo: formUrl
                    }),
                    success: function (res) {
                        console.log(res)
                        init()
                    }
                })
            }
            // 打开院校详细信息
            var tbody2 = document.querySelector('#tbody2')
            function view(ides) {
                sessionStorage.setItem('school_id',ides)
                tbody2.innerHTML = ''
                document.querySelector('.view').style.display = 'block'
                var arr;

                xhr({
                    methods: 'post',
                    url: '/student/getList',
                    data: JSON.stringify({
                        page: 1,
                        limit: 5,
                        student_school: ides
                    }),
                    success: function (res) {
                        console.log(res)
                        arr = res
                        data2 = res.length
                    }
                })
                xhr({
                    methods: 'get',
                    url: '/user/getSchool',
                    success: function (res) {
                        console.log(res)
                        for (var i in res) {
                            if (res[i].school_id == ides) {
                                // schoolLogo.src = res[i].school_logo
                                schoolLogo.src = '../1.PNG'
                            }
                        }
                    }
                })
                xhr({
                    methods: 'get',
                    url: `/rankSys/getFn?school_id=${Number(ides)}`,
                    success: function (res) {
                        console.log(res)
                        var tablearr = []
                        for (var i in res) {
                            console.log(res[i])
                            if (res[i].page_id == '1') {
                                tablearr.push(res[i].page_id)
                            }
                            if (res[i].page_id == '2') {
                                tablearr.push(res[i].page_id)
                            }
                        }
                        console.log(tablearr)
                        if (tablearr.includes(1) == true && tablearr.includes(2) == true) {
                            theadstu.innerHTML = `<tr>
                        <th>序号</th>
                        <th>学生姓名</th>
                        <th>专业</th>
                        <th>班级</th>
                        <th>入学时间</th>
                        <th>当前学年学分</th>
                        <th>搜属地</th>
                        <th>性别</th>
                        <th>联系方式</th>
                        <th>操作</th>
                    </tr>`
                            xhr({
                                methods: 'get',
                                url: `/specialty/get?school_id=${Number(ides)}`,
                                success: function (res) {
                                    console.log(res)
                                    var zy = res
                                    specialty.style.display = 'block'
                            grades.style.display = 'block'
                            searchstucx.style.display = 'block'
                                    specialty.innerHTML = `<option value=''>请选择专业</option>`
                                    for (var i in res) {
                                        specialty.innerHTML += `<option value="${res[i].specialty_id}">${res[i].specialty_name}</option>`
                                    }
                                    for (var k = 0; k < zy.length; k++) {
                                        for (var i = Number(studentys.innerHTML - 1) * 5; i < arr.length; i++) {
                                            if (res[k].specialty_id == arr[i].specialty_id) {
                                                if(arr[i].atScore){
                                                    tbody2.innerHTML += `
                                                    <tr>
                                                    <td>${i + 1}</td> 
                                                    <td>${arr[i].student_name}</td>
                                                    <td>${zy[k].specialty_name}</td>
                                                    <td>${arr[i].student_class}</td>
                                                    <td>${arr[i].student_age}</td>
                                                    <td>${arr[i].atScore}</td>
                                                    <td>${arr[i].student_address}</td>
                                                    <td>${arr[i].student_sex}</td>
                                                    <td>${arr[i].student_phone}</td>
                                                    <td><button class="btn btn-primary m-r-5" onclick="behavioralExpressionBox(${arr[i].Id})">过往表现</button>
                                                    </td>
                                                </tr>
                                                    `
                                                }else{
                                                    tbody2.innerHTML += `
                                                    <tr>
                                                    <td>${i + 1}</td> 
                                                    <td>${arr[i].student_name}</td>
                                                    <td>${zy[k].specialty_name}</td>
                                                    <td>${arr[i].student_class}</td>
                                                    <td>${arr[i].student_age}</td>
                                                    <td>---</td>
                                                    <td>${arr[i].student_address}</td>
                                                    <td>${arr[i].student_sex}</td>
                                                    <td>${arr[i].student_phone}</td>
                                                    <td><button class="btn btn-primary m-r-5" onclick="behavioralExpressionBox(${arr[i].Id})">过往表现</button>
                                                    </td>
                                                </tr>
                                                    `
                                                }
                                                        
                                                
                                            }
                                        }
                                    }
                                }
                            })
                            xhr({
                                methods: 'get',
                                url:`/gradeAndClass/getGradeAndClass?grade_school_id=${Number(ides)}`,
                                success:function(res){
                                    console.log(res)
                                    var nj = res
                                    grades.innerHTML = `<option value="">请选择年级</option>`
                                    for (var i in res) {
                                        grades.innerHTML += `<option value="${res[i].Id}">${res[i].grade_name}</option>`
                                    }
                                }
                            })
                            return
                        } else {
                            specialty.style.display = 'none'
                            grades.style.display = 'none'
                            searchstucx.style.display = 'none'
                            theadstu.innerHTML = `<tr>
                        <th>序号</th>
                        <th>学生姓名</th>
                        <th>入学时间</th>
                        <th>当前学年学分</th>
                        <th>搜属地</th>
                        <th>性别</th>
                        <th>联系方式</th>
                        <th>操作</th>
                        </tr>`
                            for (var i = Number(studentys.innerHTML - 1) * 5; i < arr.length; i++) {
                                if(arr[i].atScore){
                                                    tbody2.innerHTML += `
                                                    <tr>
                                                    <td>${i + 1}</td> 
                                                    <td>${arr[i].student_name}</td>
                                                    <td>${arr[i].student_class}</td>
                                                    <td>${arr[i].student_age}</td>
                                                    <td>${arr[i].atScore}</td>
                                                    <td>${arr[i].student_address}</td>
                                                    <td>${arr[i].student_sex}</td>
                                                    <td>${arr[i].student_phone}</td>
                                                    <td><button class="btn btn-primary m-r-5" onclick="behavioralExpressionBox(${arr[i].Id})">过往表现</button>
                                                    </td>
                                                </tr>
                                                    `
                                                }else{
                                                    tbody2.innerHTML += `
                                                    <tr>
                                                    <td>${i + 1}</td> 
                                                    <td>${arr[i].student_name}</td>
                                                    <td>${arr[i].student_class}</td>
                                                    <td>${arr[i].student_age}</td>
                                                    <td>---</td>
                                                    <td>${arr[i].student_address}</td>
                                                    <td>${arr[i].student_sex}</td>
                                                    <td>${arr[i].student_phone}</td>
                                                    <td><button class="btn btn-primary m-r-5" onclick="behavioralExpressionBox(${arr[i].Id})">过往表现</button>
                                                    </td>
                                                </tr>
                                                    `
                                                }
                                                }
                        }
                        if (tablearr.includes(1) == true) {
                            specialty.style.display = 'none'
                            grades.style.display = 'block'
                            searchstucx.style.display = 'block'
                            theadstu.innerHTML = `<tr>
                        <th>序号</th>
                        <th>学生姓名</th>
                        <th>专业</th>
                        <th>入学时间</th>
                        <th>当前学年学分</th>
                        <th>搜属地</th>
                        <th>性别</th>
                        <th>联系方式</th>
                        <th>操作</th>
                    </tr>`
                    xhr({
                                methods: 'get',
                                url: `/specialty/get?school_id=${Number(ides)}`,
                                success: function (res) {
                                    console.log(res)
                                    for (var k = 0; k < res.length; k++) {
                                        for (var i = Number(studentys.innerHTML - 1) * 5; i < arr.length; i++) {
                                            if (res[k].specialty_id == arr[i].specialty_id) {
                                                if(arr[i].atScore){
                                                    tbody2.innerHTML += `
                                                    <tr>
                                                    <td>${i + 1}</td> 
                                                    <td>${arr[i].student_name}</td>
                                                    <td>${zy[k].specialty_name}</td>
                                                    <td>${arr[i].student_age}</td>
                                                    <td>${arr[i].atScore}</td>
                                                    <td>${arr[i].student_address}</td>
                                                    <td>${arr[i].student_sex}</td>
                                                    <td>${arr[i].student_phone}</td>
                                                    <td><button class="btn btn-primary m-r-5" onclick="behavioralExpressionBox(${arr[i].Id})">过往表现</button>
                                                    </td>
                                                </tr>
                                                    `
                                                }else{
                                                    tbody2.innerHTML += `
                                                    <tr>
                                                    <td>${i + 1}</td> 
                                                    <td>${arr[i].student_name}</td>
                                                    <td>${zy[k].specialty_name}</td>
                                                    <td>${arr[i].student_age}</td>
                                                    <td>---</td>
                                                    <td>${arr[i].student_address}</td>
                                                    <td>${arr[i].student_sex}</td>
                                                    <td>${arr[i].student_phone}</td>
                                                    <td><button class="btn btn-primary m-r-5" onclick="behavioralExpressionBox(${arr[i].Id})">过往表现</button>
                                                    </td>
                                                </tr>
                                                    `
                                                }
                                            }
                                        }
                                    }
                                }
                            })
                        }
                        if (tablearr.includes(2) == true) {
                            specialty.style.display = 'block'
                            grades.style.display = 'none'
                            searchstucx.style.display = 'block'
                            theadstu.innerHTML = `<tr>
                        <th>序号</th>
                        <th>学生姓名</th>
                        <th>班级</th>
                        <th>入学时间</th>
                        <th>当前学年学分</th>
                        <th>搜属地</th>
                        <th>性别</th>
                        <th>联系方式</th>
                        <th>操作</th>
                    </tr>`
                    for (var i = Number(studentys.innerHTML - 1) * 5; i < arr.length; i++) {
                                            if (res[k].specialty_id == arr[i].specialty_id) {
                                                if(arr[i].atScore){
                                                    tbody2.innerHTML += `
                                                    <tr>
                                                    <td>${i + 1}</td> 
                                                    <td>${arr[i].student_name}</td>
                                                    <td>${arr[i].student_class}</td>
                                                    <td>${arr[i].student_age}</td>
                                                    <td>${arr[i].atScore}</td>
                                                    <td>${arr[i].student_address}</td>
                                                    <td>${arr[i].student_sex}</td>
                                                    <td>${arr[i].student_phone}</td>
                                                    <td><button class="btn btn-primary m-r-5" onclick="behavioralExpressionBox(${arr[i].Id})">过往表现</button>
                                                    </td>
                                                </tr>
                                                    `
                                                }else{
                                                    tbody2.innerHTML += `
                                                    <tr>
                                                    <td>${i + 1}</td> 
                                                    <td>${arr[i].student_name}</td>
                                                    <td>${arr[i].student_class}</td>
                                                    <td>${arr[i].student_age}</td>
                                                    <td>---</td>
                                                    <td>${arr[i].student_address}</td>
                                                    <td>${arr[i].student_sex}</td>
                                                    <td>${arr[i].student_phone}</td>
                                                    <td><button class="btn btn-primary m-r-5" onclick="behavioralExpressionBox(${arr[i].Id})">过往表现</button>
                                                    </td>
                                                </tr>
                                                    `
                                                }
                                                        
                                                
                                            }
                                        }
                        }
                    }
                })

            }
            function closeview() {
                document.querySelector('.view').style.display = 'none'
            }
            //打开和关闭添加院校菜单
            function addschool() {
                // addacademy.innerHTML = ``
                addacademy.style.transform = 'translateX(-560px)'
            }
            function closeaddacademy() {
                addacademy.style.transform = 'translateX(0)'
                addacademy.innerHTML = ''
            }
            function files() {
                fileS.click()
            }
            fileS.addEventListener('change', function () {
                var file = fileS.files[0]
                var form = new FormData()
                form.append('file', file)
                xhr({
                    url: '/upload/upload',
                    methods: 'post',
                    header: {},
                    data: form,
                    success: function (res) {
                        console.log(res)
                        formUrl = res
                    }
                })
            })

            //打开和关闭过往表现菜单
            function behavioralExpressionBox(i) {
                document.querySelector('.behavioralExpression').style.transform = 'translateX(-560px)'
                                                xhr({
                                                    methods: 'post',
                                                    url: '/student/getStudentDetail',
                                                    data:JSON.stringify({
                                                        id:i
                                                    }),
                                                    success: function (res) {
                                                        console.log(res)
                                                        data3 = res.studentManifestation.length
                                                        var behavioralExpressionystbody = document.querySelector('.behavioralExpressionystbody')
                                                        behavioralExpressionystbody.innerHTML = ''
                                                        console.log(behavioralExpressionys)
                                                            for (var i = Number(behavioralExpressionys.innerHTML - 1) * 5; i < res.studentManifestation.length; i++){
                                                            behavioralExpressionystbody.innerHTML += `
                                                                <tr>
                                                                    <td>${i + 1}</td>
                                                                    <td>${ res.studentManifestation[i].occurrence_time}</td>
                                                                    <td>${ res.studentManifestation[i].occurrence_content}</td>
                                                                </tr>
                                                                `
                                                        }
                                                    }
                                                })
                                            }
                                            function closebehavioralExpression() {
                                                document.querySelector('.behavioralExpression').style.transform = 'translateX(0)'
            }

        </script>
</body>

</html>